From 0e50828b2e59b14a2356a851fc9e96a0940b79f7 Mon Sep 17 00:00:00 2001 From: Viet-Tam Luu Date: Sat, 1 Aug 2020 12:57:22 -0700 Subject: [PATCH] Fix NMEA parsing creating Null Island waypoints (#607) * Fix NMEA parsing creating Null Island waypoints Fix parsing of NMEA GPGGA sentences: ones with 0 "fix quality" (i.e. "invalid") are allowed in serial (i.e. live GPS) mode because (according to the comment) some GPS devices will report previously-read data in the absence of a current good fix. Adjust this allowance to require an actual coordinate value; at least one popular USB GPS device will issue GPGGA such as "$GPGGA,010222.00,,,,,0,00,99.99,,,,,,*65" if it loses a good fix, and the empty lat/lng coordinates (",,,,,") are parsed as 0N 0W (a.k.a. "Null Island"). QString::toDouble() won't report a problem with an empty input so we simply check for 0 lat/lng. * Use "ok" QString::toDouble() argument instead ... of checking for checking for both lat & lng exactly zero, as `ok` does indeed get set to `false` on empty inputs, in recent Qt versions. * Revert "Use "ok" QString::toDouble() argument instead" This reverts commit d226d01c862606615aa599f5d3b649cea12f0700. --- nmea.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nmea.cc b/nmea.cc index 9de6c7942..6be06f149 100644 --- a/nmea.cc +++ b/nmea.cc @@ -426,11 +426,12 @@ NmeaFormat::gpgga_parse(char* ibuf) /* * In serial mode, allow the fix with an invalid position through + * (unless if the position lat/lng is absent or completely bogus) * as serial units will often spit a remembered position up and * that is more comfortable than nothing at all... */ CHECK_BOOL(opt_ignorefix); - if ((fix <= 0) && (read_mode != rm_serial) && (!opt_ignorefix)) { + if ((fix <= 0) && (read_mode != rm_serial || (latdeg == 0.0 && lngdeg == 0.0)) && (!opt_ignorefix)) { return; } -- 2.30.2